#ifndef _K2chTextView_
#define _K2chTextView_
//-------------------------------------------------------------------------------------------------------
//      Copyright (c) 2005-2009, Be Nanashi-San 
// 
//      Permission is hereby granted, free of charge, to any person obtaining a 
//      copy of this software and associated documentation files (the "Software"), 
//      to deal in the Software without restriction, including without limitation 
//      the rights to use, copy, modify, merge, publish, distribute, sublicense, 
//      and/or sell copies of the Software, and to permit persons to whom the 
//      Software is furnished to do so, subject to the following conditions: 
// 
//      The above copyright notice and this permission notice shall be included in 
//      all copies or substantial portions of the Software. 
// 
//      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
//      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
//      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
//      FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
//      DEALINGS IN THE SOFTWARE. 
// 
//      File Name:   	K2chTextView.h
//      Author:      	Be Nanashi-San@598 in "BeOS - Zeta R4" Thread 
//						(http://pc8.2ch.net/test/read.cgi/os/1120676818/598)
//		Description:	互換K2chTextView.
//-------------------------------------------------------------------------------------------------------
#include "Base2chTextView.h"
#include "MonaList.h"
#include "MUtils.h"
#include <SupportDefs.h>
#include <vector>

enum disp_mode{
	DISP_ALL_THREAD,
	DISP_PARTIAL_THREAD
};

class BPopUpMenu;
class MSticker;
class K2chTextView : public Base2chTextView
{
	public:
		K2chTextView(const char *name, uint32 flags = B_WILL_DRAW | B_PULSE_NEEDED);
		virtual ~K2chTextView(); 
		void KeyDown(const char* bytes, int32 numBytes);
		void MessageReceived(BMessage *msg);
		void MouseDown(BPoint where);
		void MouseUp(BPoint where);
		void MouseMoved(BPoint where, uint32 code, const BMessage *msg);
		void FindString(const char *search);
		void LoadFile(BFile &file);
		void ScrollToRes(int32 thread_no);
		void Pulse();

		void SetDispmode(disp_mode mode);
		disp_mode Dispmode();
		void AddMenuItems(BPopUpMenu *menu, BPoint where);
		void AddResMenuItem(BPopUpMenu *menu, const char *msg, uint32 command);
		bool AcceptReload();
		void UpdatePreferences(BMessage *msg);
		void MakeFocus(bool focused = true);
		void TargetedByScrollView(BScrollView* scrollView);		
		private:
		void AutoScroll(bool last_in, int32 top_thread_no);
		void InsertThread(int32 i, Base2chTextView *outView);
		void ClearText();
		void PostStatus(const char *title);
		void StopLoad();
		void LoadText(int32 range = 0, int32 scroll_thread_no = 0);

		void AppendThread(int32 offset, uint32 seek_mode, disp_mode dmode);
		void Seek(int32 offset, uint32 seek_mode);
		static int32 InsertMonaRun(void *data);
		void InsertMona();
		void InvokeThread(int32 thread_no);
		void Invoke();		
		void SelectionInvoke();
		void SetInvoke(const char *name, int32 length);
		void SetInvoke(const char *name, int32 size, int32 length);

		void ShowTipWindow(int32 thread_no);
		void ThreadSelection(BPoint where, int32 &start, int32 &end);
		void UpdateThreadNo(BFile *file);
		void GoogleSearch(const char* searchText);

		MActionList	fAction;
	//	bool fReloaded;
		thread_id fThread_id;
		bool fCancel;
		//BFile fFile;
		MSticker *fTipStiker;
		MonaList fDat;
		int32 fCurPositon;
		disp_mode fDispmode;
		int32 fThreadDisplayRange;
		int32 fRange, fScrollThreadNo;	// by be7743
		int32 fCursorOffset;
		int32 fCountTimer;
		std::vector<int32> fThread;
		BScrollView *fScrollView;
};

#endif
